﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Urna_virtual.Models.UrnaModels;

namespace Urna_virtual.Controllers
{
    public class VotoController : Controller
    {
        public UrnaContext db = new UrnaContext();
        //
        // GET: /Voto/
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Voto(int DNI, int id)
        {
            Votante unVotante = db.Votantes.Find(DNI);
            if (unVotante == null)
            {
                return HttpNotFound();
            }
            if (unVotante.voto == true)
            {
                return RedirectToAction("Error");
            }
            unVotante.voto = true;
            return View();
        }

        private ActionResult Error()
        {
            return View();
        }
    }
}
